package com.example.webtest.controller;

import io.netty.util.Recycler;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Objects;

@Component
public class tokenintercept implements HandlerInterceptor {
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		Object token = request.getSession().getAttribute("pp");
		if(Objects.isNull(token)){
			response.setCharacterEncoding("utf-8");
			response.getWriter().write("请不要重复提交");
			return false;
		}

		return true;
	}
}
